<style lang="scss">
	page{
		background: #FFFFFF;
	}
	.flex{
		display: flex;
		align-items: center;
	}
	.bgWhite{
		background: #FFFFFF;
	}
	
	.orderInfo{
		padding: 24rpx 38rpx;
		padding-top: 0;
		margin-bottom: 20rpx;
		.no{
			color: #595959;
			font-size: 30rpx;
			border-bottom: 1px solid #e6e6e6;
			line-height: 74rpx;
		}
		.prodInfo{
			padding: 24rpx 0;
			.pic{
				width: 117rpx;
				height: 117rpx;
				display: block;
				border-radius: 10rpx;
				margin-right: 30rpx;
				margin-left: 6rpx;
			}
			.info{
				font-size: 32rpx;
				flex: 1;
				.name{
					color: #4c4c4c;
					font-size: 32rpx;
					line-height: 50rpx;
				}
				.flex{
					justify-content: space-between;
					margin-top: 10rpx;
				}
				.price{
					color: #d71511;
					font-weight: bold;
				}
				.num{
					color: #717171;
				}
			}
		}
		.time{
			color: #e62c2c;
			font-size: 30rpx;
		}
	}
	.keep-list{
		&-item{
			&-title{
				background-color: #f7d6d5;
				line-height: 66rpx;
				text{
					color: #191919;
					font-size: 31rpx;
					width: 25%;
					text-align: center;
				}
			}
			&-content{
				&-title{
					height: 100rpx;
					.text{
						color: #676767;
						font-size: 28rpx;
						width: 25%;
						text-align: center;
					}
					.btn{
						justify-content: center;
					}
					.cancelColor{
						color: #ee2d88;
					}
					.sureColor{
						color: #db1611;
					}
				}
				&-list{
					&-head{
						line-height: 60rpx;
						background-color: #ebebeb;
					}
					text{
						color: #343434;
						font-size: 28rpx;
						width: 33.33%;
						text-align: center;
						line-height: 70rpx;
					}
					&-info:nth-child(odd){
						background-color: #f5f5f5;
					}
					&-emty{
						font-size: 28rpx;
						text-align: center;
						padding: 20rpx 0;
					}
				}
			}
		}
	}
	.keep-upBtn-cont{
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		.keep-tips{
			color: #db1611;
			font-size: 28rpx;
			padding: 0 40rpx;
			height: 90rpx;
			background-color: #FFFFFF;
			text{
				margin-left: 10rpx;
			}
		}
		.keep-upBtn{
			height: 90rpx;
			line-height: 90rpx;
			color: #FFFFFF;
			background-color: #db1611;
			font-size: 30rpx;
			text-align: center;
		}
	}
	
	.keep-upBtn-emty{
		width: 100%;
		height: 180rpx;
	}
	
</style>

<template>
	<view >
		<view class="content">
			<view class="orderInfo ">
				<view class="no">订单：{{orderData.order_no}}</view>
				<view class="prodInfo flex">
					<image class="pic" :src="jewelry.goods_img"></image>
					<view class="info">
						<view class="name">{{jewelry.goods_name}}</view>
						<view class="flex"><text class="price">¥{{jewelry.shop_price}}</text><text class="num">x{{jewelry.buy_num}}</text></view>
					</view>
				</view>
				<!-- <view class="time">寄存时间：{{orderData.keep_time}}</view>
				<view class="time">寄存结束时间：{{orderData.keep_time_end}}</view>
				<view class="time" v-if="is_keep_day">寄存期限：{{orderData.keep_day}}</view> -->
			</view>
			<view class="keep-list">
				<view class="keep-list-item">
					<view class="keep-list-item-title flex">
						<text>寄存时间</text>
						<text>寄存信息</text>
						<text>寄存金额</text>
						<text>状态</text>
					</view>
					<view class="keep-list-item-content" @tap="toggle">
						<view class="keep-list-item-content-title flex">
							<view class="text">{{orderData.time_begin_text}}<br>{{orderData.time_end_text}}</view>
							<view class="text">{{orderData.consign_time_text}}/{{orderData.consign_rate}}%<br>{{orderData.consign_awarded}}/{{orderData.consign_total_period}}期</view>
							<view class="text cancelColor" :class="[{'cancelColor':orderData.stuate == 0},{'sureColor':orderData.stuate == 1}]">￥{{orderData.consign_price||0}}</view>
							<view class="text btn flex" 
							:class="[{'cancelColor':orderData.stuate == 0},{'sureColor':orderData.stuate == 1}]">{{orderData.consign_state_text}}
							<arrow color="#666666" size="40" :direction="isShow?'top':'bottom'"></arrow></view>
						</view>
						<view class="keep-list-item-content-list" v-if="isShow">
							<view class="keep-list-item-content-list-head flex">
								<text>时间</text>
								<text>金额</text>
								<text>状态</text>
							</view>
							<view class="keep-list-item-content-list-info flex" v-for="(list,idx) in orderData.log_list" :key="idx" v-if="orderData.log_list.length > 0">
								<text>{{list.create_time_text}}</text>
								<text>{{list.amount}}</text>
								<text>{{list.is_accept_text}}</text>
							</view>
							<view class="keep-list-item-content-list-emty" v-if="orderData.log_list.length === 0">暂无数据</view>
						</view>
					</view>
				</view>
				
			</view>
			
			<view class="keep-upBtn-emty"></view>
			<view class="keep-upBtn-cont">
				<view class="keep-tips flex"><icon type="warn" color="#db1611" size="17"/><text>如提前取消寄存会收取额外费用</text></view>
				<view class="keep-upBtn" @tap='cancel_consignation(orderData.order_id, 1)'>取消寄存</view>
			</view>
		</view>
		<view class="m-full-loading" v-if="bIsShowLoading">
		    <image src="../../../static/images/loading.gif"></image>
		</view>
	</view>
</template>
<script>
	
	import henglang from '@/common/common_zb.js';
	export default {
		data() {
			return {
				orderData: [],
				page: 1,	// 当前页数
				totalPages: 1,	// 页数总数
				loadtype: 'normal',	// 加载数据方式
				bIsShowLoading: false,
				showNodata: false,
				order_no: '',
				is_keep_day: 0,
				direction: true,
				jewelry:{},
				isShow:false
			};
		},
        methods: {
			cancel_consignation(order_id, type) {
				let that = this;
				if(type == 1) {
					uni.showModal({
						title: '提示',
						content: '确认要取消寄存该订单吗',
						success: function (res) {
							if (res.confirm) {
								henglang.post('order/cancel_consignation', {order_id: order_id}, true, function (res){
									let resdata = res.data;
									if(resdata.code == '0') {
										henglang.showToast(resdata.msg);
									}else if(resdata.code == 2) {
										uni.showModal({
											title: '提示',
											content: resdata.msg,
											success: function (res) {
												if (res.confirm) {
													that.cancel_consignation(order_id, 2);
												}
											}
										})
									}else{
										henglang.showToast(resdata.msg);
									}
								})
							}
						}
					})
				}else{
					henglang.post('order/cancel_consignation', {order_id: order_id, toast: 1}, true, function (res){
						let resdata = res.data;
						henglang.showToast(resdata.msg);
						if(resdata.code == '0') {
						}
					})
				}
				
			},
			getLog(data) {
				let that = this;
				that.bIsShowLoading = true;
				if(that.page <= that.totalPages){
					data.page = that.page;
					henglang.post('agent_jewel/getTypeLog',data, true,function(res){
						that.bIsShowLoading = false;
						if(res.data.total_pages == 0) {
							that.showNodata = true;
						}
						if (!res.data.data.length) {
							that.logData = ''
							return false;
						}
						if (that.loadtype == "plus") { // 上拉加载
							that.logData = that.logData.concat(res.data.data);
						} else {
							that.logData = res.data.data;
							that.totalPages = res.data.total_pages;
							uni.stopPullDownRefresh();
						}
					});
				}else{
					that.bIsShowLoading = false
				}
			},
			toggle() {
				this.isShow = !this.isShow
			}
        },
        onLoad({order_no}) {
			let that = this;
			that.order_no = order_no;
			that.bIsShowLoading = true;
			henglang.post('order/consignation', {order_no: order_no}, true, function (res){
				that.bIsShowLoading = false;

				if(res.data.code=='-1') {
					hl.showToast(res.data.msg, 1000);
					setTimeout(function(){
						uni.navigateBack();
					}, 1500)
				}else{

					that.orderData = res.data.data[0];
					that.jewelry = res.data.data[0].jewelry
				}
			})
        }
	}
</script>

